<%--@ page language="java" import="java.util.*" pageEncoding="UTF-8"--%>
<%@ page contentType="text/html;charset=UTF-8" language="java"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
	String url = request.getParameter("url");
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
	<head>
		<base href="<%=basePath%>">
		<base target="_self">

		<title>选择文件</title>

		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
		<meta http-equiv="pragma" content="no-cache">
		<meta http-equiv="cache-control" content="no-cache">
		<meta http-equiv="expires" content="0">
		<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
		<meta http-equiv="description" content="This is my page">
		<link rel="stylesheet" type="text/css"
			href="<%=path%>/web/style/layout.css" />
		<script type="text/javascript"
			src="<%=path%>/jqGrid/js/jquery-1.7.2.min.js"></script>
		<script type="text/javascript"
			src="<%=path%>/jslib/jquery.validate.min.js"></script>
		<script type='text/javascript'
			src="<%=request.getContextPath()%>/jslib/My97DatePicker/WdatePicker.js"
			defer="defer"></script>
		<script type='text/javascript'
			src="<%=request.getContextPath()%>/jslib/jquery.form.js"></script>
		<script type="text/javascript"
			src="<%=request.getContextPath()%>/jslib/additional-methods.js"></script>
		<link rel="stylesheet" type="text/css"
			href="<%=request.getContextPath()%>/jslib/jquery-easyui-1.4.1/themes/default/easyui.css">
		<link rel="stylesheet" type="text/css"
			href="<%=request.getContextPath()%>/jslib/jquery-easyui-1.4.1/themes/icon.css">
		<link rel="stylesheet" type="text/css"
			href="<%=request.getContextPath()%>/jslib/jquery-easyui-1.4.1/demo.css">
		<script type="text/javascript"
			src="<%=request.getContextPath()%>/jslib/jquery-easyui-1.4.1/jquery.easyui.min.js"></script>
		<script type="text/javascript"
			src="<%=request.getContextPath()%>/jslib/lhgdialog/lhgcore.lhgdialog.min.js?skin=mac"></script>
		<c:if test="${requestScope.message!=null}">
			<script type="text/javascript">
  	 			alert('<c:out value="${requestScope.message}"></c:out>');
  	 			window.close();
  			</script>
		</c:if>
		<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->

		<script type="text/javascript">
	var type = '<%=request.getParameter("type")%>';
	var api;
	 $().ready(function() {
		 function chexkAll(){
		 	var filename = document.getElementById('filePath').value;
			return true; 
		 }

		// 准备好Options对象
	    	var options = {
	    	    url:'<%=request.getContextPath()%>/'+type+'',
	    	    beforeSubmit: function() {	
	    	    	//Excel文件
	    	    	var fileExcel = document.getElementById("filePath").files;  
	    	        var filenameExcel;
	    	        if(fileExcel[0]==null)
	    	        {
	    	        	filenameExcel="";
	    	        }
       				else
       				{       				
       					filenameExcel=fileExcel[0].name;
       				}	   
       				    	
	    	    	//PDF文件    	    	
	    	        var filePDF = document.getElementById("filePDF").files;  
	    	        var filenamePDF;
	    	        if(filePDF[0]==null)
	    	        {
	    	        	filenamePDF="";
	    	        }
       				else
       				{       				
       					filenamePDF=filePDF[0].name;
       				}
       				if(filenamePDF!=""&&filenamePDF.indexOf("zip")<0)
       				{
       					alert("PDF文件需为zip格式！");
       					api.close();
       					return false;
       				}
       				$("#filenamePDF").val(filenamePDF);
       				//照片
       				var filePhoto = document.getElementById("filePhoto").files; 
       				var filenamePhoto;
       				if(filePhoto[0]==null)
       				{
       					filenamePhoto="";
       				}
       				else
       				{
       					filenamePhoto=filePhoto[0].name;
       				}       
       				if(filenamePhoto!=""&&filenamePhoto.indexOf("zip")<0)
       				{
       					alert("照片文件需为zip格式！");
       					api.close();
       					return false;
       				}
       				 	
       				$("#filenamePhoto").val(filenamePhoto);        				     			 
	    		    var date =  $('#pageFrom').form('enableValidation').form('validate');
	    		   if(!date){
						return false;
		    		  }
	    		    return chexkAll();
	    		},
	    	    dataType:'json',
	    	    success: function(data) {
	    	      if(data.result=='success'){
	    	      		api.close();
						alert("导入成功");
						window.close();
						window.opener.gridSearch();
	    	      }else{
	    	      	api.close();
	    	      	alert("导入出错:"+data.result);
	    	      	if(data.result!="请选择附件"&&data.result!="请选择照片")
	    	      	{
	    	      		window.close();
						window.opener.gridSearch();
	    	      	}
	    	      	
	    	      	//alert("文件有误");
	    	      	//alert("系统忙，请稍后重试！");
	    	      	return;
	    	      }
	    	    }};
			$('#saveBtn').click(function(){	 
				
				$('#pageFrom').ajaxSubmit(options);
				api = $.dialog.tips('数据加载中...',600,'loading.gif'); 
				return false;
				
			});
	 });
	function closeqa(){
		window.close();
	}
	 
	</script>
	</head>
	<body>
		<form action="" id="pageFrom" enctype="multipart/form-data"
			method="post">

			<table width="400" border="0" align="center" cellpadding="5"
				cellspacing="5" class="formTableNew" style='margin-top: 100px;'>
				<tr align="center">

					<td align="center">
					<input type="hidden" name="filenameExcel" id="filenameExcel">
						&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp数据文件：
						<input type="file" name="filePath" id="filePath">
					</td>
				</tr>
				<tr align="center">
					<td align="center">
						<input type="hidden" name="filenamePDF" id="filenamePDF" >
						&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp附件(zip格式)：
						<!--  PDF文件(zip格式)：-->
						<input type="file" name="filePDF" id="filePDF" accept="*.zip">
					</td>
				</tr>
				<tr align="center">
					<td align="center">
						<input type="hidden" name="filenamePhoto" id="filenamePhoto" >
						&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp照片(zip格式)：
						<input type="file" name="filePhoto" id="filePhoto" accept="*.zip">
					</td>
				</tr>
				<tr>
					<td>
						<br />
						<br />
						<br />
						<br />
					</td>
				</tr>
				<tr align="center">
					<td colspan="2" align="center">
						<input type="button" id="saveBtn" value="确 定"
							class="form_bt_orange" />
						<input type='button' value='取 消' onclick="closeqa();"
							class="search_Btn" />
					</td>
				</tr>
			</table>
			<input type='hidden' name='formId' id='formId'
				value='<%=request.getParameter("formId")%>' />
		</form>
	</body>
</html>
